/**
 * @project name:crm
 */
package com.yunbo.crm.config;

import com.yunbo.crm.interceptor.NoLoginInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;

/**
 * @Author : yun&bo
 * @CreateDate : ==>2021/1/21 11:39
 * @ClassName : ==>
 * @Description : ==>
 * @Version
 */
@Configuration
public class MVCConfig implements WebMvcConfigurer {
    /**
     * 特别注意此处的执行顺序  如果这里没有注入拦截器，而是用的new的方法  则因为顺序问题 不能扫描到
     */
    @Resource
    private NoLoginInterceptor noLoginInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        InterceptorRegistration registration = registry.addInterceptor(noLoginInterceptor);
        registration.addPathPatterns("/**");
        registration.excludePathPatterns("/index", "/user/login", "/css/**", "/images/**", "/js/**", "/lib/**");
    }

}
